from gym_pih.hardware.RealsenseCamera import Camera
import cv2

cam=Camera()
cam.Open()
# _,image=cam.GetImage()
# print(image.shape)
try:
    while True:
        
        _,image=cam.GetImage()
        image_clip=image[160:224,210:274]
        # cv2.namedWindow('image',cv2.WINDOW_NORMAL)
        # cv2.imshow('image',image)
        image_shape = image.shape
        image_shape = list(image_shape)
        image_shape[:2]=[int(x * (640 / image_shape[1])) for x in image_shape[:2]]
        image_shape = tuple(image_shape)
        cv2.namedWindow('image_clip',cv2.WINDOW_NORMAL)
        cv2.resizeWindow('image_clip',image_shape[1],image_shape[0])
        cv2.imshow('image_clip',image)
        cv2.waitKey(1)
finally:
    cam.Close()
    cv2.destroyAllWindows()


